﻿using System;
using Best.SmartCms.Core.Utility;
using Best.SmartCms.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NLog;

namespace Best.SmartCms.API.Controllers
{

    /// <summary>
    /// 
    /// </summary>
    public class CheckAliveController : Controller
    {
        private const string CheckAliveResponse = "OK";
        private readonly ILogger _logger = NLog.LogManager.GetCurrentClassLogger();

        /// <summary>
        /// 检测站点是否存活
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        [HttpGet]
        [HttpHead]
        [Route("CheckAlive")]
        [Route("CheckAlive.ashx")]
        public string CheckAlive()
        {
            try
            {
                _logger.Error("test");
                _logger.Debug("LogDebug");
                _logger.Info("LogInfo");
                _logger.Warn("LogWarn");
                _logger.Trace("LogTrace");

                NLogManager.LogError("test");
                NLogManager.LogDebug("LogDebug");
                NLogManager.LogInfo("LogInfo");
                NLogManager.LogWarn("LogWarn");
                NLogManager.LogTrace("LogTrace");
                return CheckAliveResponse;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return CheckAliveResponse;
            }
        }
    }
}